//
//  ZCSerchViewController.m
//  03地图定位
//
//  Created by 张聪 on 16/7/25.
//  Copyright © 2016年 张聪. All rights reserved.
//

#import "ZCSerchViewController.h"
#import "Masonry.h"
#import "ZCBaiduViewController.h"

@interface ZCSerchViewController ()

@property (nonatomic, strong) UITextField *nameTextField;

@property (nonatomic, strong) UIButton *serchBtn;



@end

@implementation ZCSerchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor grayColor];
    

    [self settingUI];
    
}

- (void)settingUI {
    
    
    UITextField *nameTextField = [[UITextField alloc] init];
    self.nameTextField = nameTextField;
    nameTextField.font = [UIFont systemFontOfSize:13];
    nameTextField.placeholder = @"请输入兴趣点";
//    nameTextField.keyboardType = 
    [nameTextField becomeFirstResponder];
    nameTextField.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:nameTextField];
    
    
    UIButton *serchBtn = [[UIButton alloc] init];
    serchBtn.backgroundColor = [UIColor orangeColor];
    serchBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [serchBtn setTitle:@"点击搜索" forState:UIControlStateNormal];
    [serchBtn addTarget:self action:@selector(didSrechBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:serchBtn];
    
    [nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(120);
        make.leading.equalTo(self.view).offset(20);
        make.trailing.equalTo(serchBtn.mas_leading).offset(-20);
        make.height.mas_equalTo(30);
    }];
    
    [serchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(120);
        make.leading.equalTo(nameTextField.mas_trailing).offset(20);
        make.trailing.equalTo(self.view).offset(-20);
        make.height.mas_equalTo(30);
    }];
    
   
    
    
    
}

#pragma mark - 事件响应

- (void)didSrechBtnClick {
    
    [self.nameTextField resignFirstResponder];
    
    if ([self.SerchViewControllerDelegate respondsToSelector:@selector(serchInterest:)]) {
        [self.SerchViewControllerDelegate serchInterest:self.nameTextField.text ];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
    NSLog(@"搜索");
    
    
    
}

#pragma mark - 懒加载
- (UITextField *)nameTextField {
    
    if (_nameTextField == nil) {
        _nameTextField = [[UITextField alloc] init];
    }
    return _nameTextField;
}

- (UIButton *)serchBtn {
    
    if (_serchBtn == nil) {
        _serchBtn = [[UIButton alloc] init];
    }
    return _serchBtn;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
